<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/1.2.1/axios.js"></script>
</head>

<body>
    <button>发送请求</button>
    <script>
        // 获取按钮
        let btns = document.querySelectorAll('button');

        // 监听2个axios执行结果及定义回调
        btns[0].onclick = function () {
            //定义2个axios调用 
            let a1 = axios('http://api.zhibao.com:3000/movies');
            let a2 = axios('http://api.zhibao.com:3000/students');
            let p1 = axios.all([a1, a2]); //promise 状态：成功/失败 取决于的axios执行结果
            // console.log(p1);

             p1.then(val=>{
                console.log(val); //[a1,a2]
                console.log(val[0].data);
                console.log(val[1].data);
            })

            // p1.then(([movies,students])=>{
            //     // console.log(val); //[a1,a2]
            //     // console.log(val[0].data);
            //     // console.log(val[1].data);

            //     console.log(movies);
            //     console.log(students);

            // })

            //  p1.then(([movies,students])=>{
               
            //     console.log(movies.data);
            //     console.log(students.data);

            // })

        //     p1.then(([{data:movieData},{data:stuData}])=>{
        //        console.log(movieData);
        //        console.log(stuData);
        //    })


        }

    </script>
</body>

</html>